package com.sh.data.engine.web.webapi.controller.dataquality;

import com.sh.data.engine.application.model.dto.dataquality.DataQualityChartResponse;
import com.sh.data.engine.application.model.dto.dataquality.DataQualityDistributeResponse;
import com.sh.data.engine.application.model.dto.dataquality.DataQualityViewTableResponse;
import com.sh.data.engine.application.service.dataquality.DataQualityViewApplicationService;
import com.sh.data.engine.web.webapi.controller.base.response.RestResponseEntity;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author tinglan.ys
 * @description: 数据质量概览页
 * @date 2022/2/15 下午6:02
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/dataQuality/view")
@Tag(name = "数据质量概览页", description = "数据质量概览页相关API")
public class DataQualityViewController {

    @Autowired
    private DataQualityViewApplicationService dataQualityViewApplicationService;

    //    @AuthorityAnnotation(menuId = MenuEnumNew.GL, readWriteStatus = 0, isAdd = 1)
    @GetMapping("/dataDistribute")
    @Operation(summary = "数据质量问题分布")
    public RestResponseEntity<List<DataQualityDistributeResponse>> dataDistributeBY(
        @Parameter(description = "按照哪种时间类型获取分布 0-天 1-周 2-月") Integer distributeBy) {
        var result = dataQualityViewApplicationService.getDataDistribution(distributeBy);
        return RestResponseEntity.success(result);
    }

    //    @AuthorityAnnotation(menuId = MenuEnumNew.GL, readWriteStatus = 0, isAdd = 1)
    @GetMapping("/dataDisplayTable")
    @Operation(summary = "数据质量上层表信息")
    public RestResponseEntity<DataQualityViewTableResponse> dataQualityTableInfo() {
        var result = dataQualityViewApplicationService.getDataQualityTableInfo();
        return RestResponseEntity.success(result);
    }

    //    @AuthorityAnnotation(menuId = MenuEnumNew.GL, readWriteStatus = 0, isAdd = 1)
    @GetMapping("/dataDisplayChart")
    @Operation(summary = "数据质量图表展示")
    public RestResponseEntity<DataQualityChartResponse> dataQualityOverviewResponse() {
        var result = dataQualityViewApplicationService.getDataQualityOverview();
        return RestResponseEntity.success(result);
    }
}
